package com.qingfeng.medical.base.controller;

import com.qingfeng.medical.biz.auth.helper.JwtHelper;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 清风学Java
 * @version 1.0.0
 * @date 2023/4/7
 */
public abstract class BaseController {

    @Autowired
    private HttpServletRequest request;

    /**
     * 获取用户Id
     * @return
     */
    public Long getUserId(){
        return JwtHelper.getUserId(request.getHeader("token"));
    }

    public String getUserName(){
        return JwtHelper.getUsername(request.getHeader("token"));
    }

}
